package leetcode;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * description:给你个整数数组 arr，其中每个元素都 不相同。
 * 请你找到所有具有最小绝对差的元素对，并且按升序的顺序返回。
 * author:zt
 * date:2022-07-04
 */
public class leetcode1200 {
    public static void main(String[] args) {
        Person p = new Person();
        p.setName("hh"); p.setAge(1000);
        System.out.println("修改前" + p.toString());
        test(p);
        System.out.println("修改后" + p.toString());
    }
    public static void test(Person p){
        p = new Person();
        p.setAge(2);
        System.out.println(p.toString());
    }
    public List<List<Integer>> minimumAbsDifference(int[] arr) {
        Arrays.sort(arr);
        List<List<Integer>> ans = new ArrayList<>();
        int n = arr.length, min = arr[1] - arr[0];
        for (int i = 0; i < n - 1; i++) {
            int cur = arr[i + 1] - arr[i];
            if (cur < min) {
                ans.clear();
                min = cur;
            }
            if (cur == min) {
                List<Integer> temp = new ArrayList<>();
                temp.add(arr[i]); temp.add(arr[i + 1]);
                ans.add(temp);
            }
        }
        return ans;
    }
}
class Person{
    private int age;
    private String name;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "Person{" +
                "age=" + age +
                ", name='" + name + '\'' +
                '}';
    }
}
